//
// Created by Lenovo on 2023/10/2.
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 3e5+7;
long long a[N];
void solve()
{
    ll a,b;
    int n;
    cin>>a>>b>>n;
    ll sum=b;
    for(int i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        if(min(x,a)==a)sum--;
        sum+=min(x,a);
//		cout<<sum<<endl;
    }
    cout<<sum;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
        cout<<endl;
    }
    return 0;
}